let __INSERT_GLOBAL_STYLE = (function (str, resolver) {




    let tS = Date.now()

    str = str

        .replace(/\{/gi, ':{')
        .replace(/\}/gi, '};')
        .replace(/&:hover/gi, '&hover')


        .replace(/\n/g, '')//
        .replace(/\s/g, '')//
        .replace(/\r/g, '')//
        .replace(/;/g, ',')//
        .trim()


        .replace(/\{/g, '{"')
        .replace(/:/g, '":')
        .replace(/,/g, '","')
        .replace(/"}"/g, '}')
        .replace(/"}/g, '}')
        .replace(/:\w/g, (str) => (':"' + str.substring(1)))
        .replace(/&hover/gi, ':hover')
        .replace(/\/\*.*?\*\//g, function (str) {
            return '';
        })
        .replace(/"",/gi, '')

    //  .replace(/:.*?;/g,function(str){
    //     return ':"'+str.trim().substring(1,str.length-1)+'",';
    //  })
    //  .replace(/-(\w)/gi,upper);
    str = '"' + str;
    str = 'return {' + str + '}'
    str = str
        .replace(/,"\}/gi, '}')
        .replace(/:-/gi, ':"-')
    // .replace(/",\}/gi,'}')
    // str='"'+str+'}';

    // window.$v3.doNothing('str---------:',str)

    let obj = new Function(str)();

    // window.$v3.doNothing('str in load css--:',str)//--
    // window.$v3.doNothing('str in load css--:',str,obj)//--
    let cssStr = ''
    let newObj = {}, newObj1 = {}
    let obj2PathObj = (obj, parentPath = '') => {
        for (let i in obj) {
            if (window.$v3.$typeof(obj[i]) == 'object') {
                newObj[parentPath + ' ' + i] = obj[i]
                obj2PathObj(obj[i], parentPath + ' ' + i)
            }

        }
    }
    obj2PathObj(obj)


    for (let j in newObj) {
        let key = j.substring(1).replace(/\s:/g, ':')
        for (let k in newObj[j]) {
            // window.$v3.doNothing('newObj[j][k]--:',newObj[j][k],k,j)
            newObj1[key] = {}
            // for(let j in newObj){
            if (window.$v3.$typeof(newObj[j][k]) == 'string') {
                Promise.resolve().then(() => {
                    newObj1[key][k] = newObj[j][k]
                })
                // setTimeout(()=>{

                //     newObj1[key][k]=newObj[j][k]
                // })

            }
            setTimeout(() => {
                if (Object.keys(newObj1[key]).length == 0) {
                    delete newObj1[key];
                }
            })

            // }
        }

    }
    setTimeout(() => {
        // for(let l in newObj1){
        //     if(Object.values(l).length){
        //         newObj2[l]=newObj1[l]
        //     }
        // }


        for (let i in newObj1) {
            // window.$v3.doNothing(' i and new obj1---:',i,newObj1[i])

            let cssStr = (i + JSON.stringify(newObj1[i])).replace(/,/g, ';').replace(/"/g, '').replace(/\}/g, ';}')
            try {
                // window.$v3.$utils.removeRule(cssStr)
                window.$v3.$utils.insertRule(cssStr)



            } catch (e) {
                // window.$v3.doNothing('css rule e--:',e)
                throw 'css rule error,please check:' + cssStr
            }

        }

        // let cssStr=Object.entries(newObj1).map((arr)=>(arr[0]+JSON.stringify(arr[1]))).join('\n').replace(/,/g,';')

        // window.$v3.doNothing('time usage---:',Date.now()-tS)
        // // window.$v3.doNothing('newObj1--:',newObj1,cssStr)

        // cssStr=cssStr
        //     .replace(/"/g,'')
        //     .replace(/\}/g,';}')
        // window.$v3.doNothing('cssStr---:',cssStr)


        // resolver(cssStr);

        // try{
        //     // window.$v3.$utils.removeRule(cssStr)
        //     window.$v3.$utils.insertRule(cssStr)



        // }catch(e){
        //     throw 'css rule error,please check:'+cssStr
        // }


        // var style=document.createElement('style');
        // style.type='text/css';
        // if(style.styleSheet){
        //     style.styleSheet.cssText=cssStr;
        // }else{
        //     style.appendChild(document.createTextNode(cssStr));
        // }
        // document.getElementsByTagName('head')[0].appendChild(style);

    })





    // return {

    // }
})



export const loadCss=function(str){
    // window.$v3.$utils.insertRule(str)
   
}